package newdecoupling.startspringmybatis.mapper;

import newdecoupling.startspringmybatis.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {


//    @Select("select * from staff_user")

    public List<User> findAll();

    @Delete("delete from staff_user where id = #{id}")
    public int deleteSql(Integer id);

    @Insert("insert into staff_user(username,password,name,age) values (#{username},#{password},#{name},#{age})")
    public Integer addUser(User user);


    @Update("UPDATE staff_user SET username = #{username}, password = #{password}, name = #{name}, age = #{age} WHERE id = #{id}")
//    @Update("update from staff_user set username = #{username}, password = #{password}, name = #{name}, age = #{age} WHERE id = #{id}" )  //多了一个from
    public Integer updateUser(User user);

    @Select("select * from staff_user where username = #{username} and password = #{password} ")
    public List<User> findByUsernameAndPassword(@Param("username") String username,@Param("password") String password);
//    public List<User> findByUsernameAndPassword(String username, String password);


}
